<?php
defined('_JEXEC') or die('Restricted access');
$db = JFactory::getDBO();
$user = JFactory::getUser();
$session = JFactory::getSession();

$query = "SELECT * FROM #__users_extension WHERE id = ".$user->id;
$db->setQuery($query);
$user_info = $db->loadObject();
?>
<style type="text/css">
  #prd-confirm-wrapper{ width:450px;}
  #product-confirm{ float:right; margin-top:5px; display:block; color:black; text-align:center; text-decoration:none; width:80px; height:27px; background:url("templates/cafe_shop/src/images/button-7.png") 0 0 no-repeat; text-indent:-9999px;}
  .clear{ clear:both;}
</style>
<div id="shopcart-page" class="main-content clear-fix">
    <div class="content-left">						
        <div id="order-list-2">
            <!-- 
            <ul>
                <li><a class="activeCate" href="my-profile.php">Mine profil</a></li>						
                <li><a href="profile.php">Profil &amp; Betaling</a></li>
            </ul>
             -->
        </div>	
    </div>
    <div id="order-right" class="content-right">
       <div class="subCategory">
            <h1>Din bestilling</h1>
            <p>Hvis du accepterer denne rækkefølge, kan du klikke "Bestil Nu" nedenfor</p>
            <table style="width:780px; margin:0px auto; padding:10px;" width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                <td><a style=" background:url(templates/cafe_shop/src/images/imgLogo.png) no-repeat; text-indent:-9999px; width:180px; height:93px; display:block; " href="index.php">Danskcafe</a></td>
                </tr>
                <tr>
                <td colspan="1">
                    <table width="780px" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td style="background-color:#ea1d2b; padding:1px; color:white; font-size:15px; font-weight:bold;" colspan="2" >Faktura</td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px;" width="313">Faktura dato:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo date('d-m-Y', time());?></td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px;" width="313">Tidspunkt:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo date('H:i:s', time());?></td>
                      </tr>
                      <tr>
                        <td style="background-color:#ea1d2b; padding:1px; color:white; font-size:15px; font-weight:bold;" colspan="2" >Kundeinformation</td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Firma/institution:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->company;?></td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Kontaktperson:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user->name;?></td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Adresse:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->address;?></td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Postnr.:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->post;?></td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">By:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->city;?></td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Telefon/mobil:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->phone;?></td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">CVR-nr.:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->cvr;?></td>
                      </tr>
                      <tr>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">E-mail:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user->email;?></td>
                      </tr>	
                       <tr>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Kommentere:</td>
                        <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo JRequest::getVar('comment');?></td>
                      </tr> 
                   </table>
                </td>
                </tr>
                <tr>
                <td style="border-bottom: 1px solid #ea1d2b;">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td style="background-color:#ea1d2b; padding:1px; color:white; font-size:15px; font-weight:bold;" colspan="8" >Ordrelinier</td>
                        </tr>
                        <tr>
                            <td width="85" style="color:#323232; font-size:11px; text-align:center; padding:1px; ">Varenr</td>
                            <td width="241" style="color:#323232; font-size:11px; text-align:center; padding:1px; ">Varenavn</td>
                            <td width="125" style="color:#323232; font-size:11px; text-align:center; padding:1px; ">Pris/enhed</td>
                            <td width="117" style="color:#323232; font-size:11px; text-align:center; padding:1px; ">Antal</td>
                            <td width="212" style="color:#323232; font-size:11px; text-align:center; padding:1px; ">Subtotal</td>    
                        </tr>
                        <?php 
						for($i=1 ; $i<= $session->get('itemAmount'); $i ++){
							$query = "SELECT number FROM #__pr_product WHERE id = ".$session->get('id'.$i);
							$db->setQuery($query);
							$item = $db->loadObject();
                        ?>
                        <tr>
                            <td style="color:#323232; font-size:11px; text-align:center; padding:1px; "><?php echo $item->number;?></td>
                            <td style="color:#323232; font-size:11px; text-align:center; padding:1px; "><?php echo $session->get('name'.$i);?></td>
                            <td style="color:#323232; font-size:11px; text-align:center; padding:1px; "><?php echo $session->get('price'.$i);?> kr</td>
                            <td style="color:#323232; font-size:11px; text-align:center; padding:1px; "><?php echo $session->get('quantity'.$i);?></td>
                            <td style="color:#323232; font-size:11px; text-align:center; padding:1px; "><?php echo $session->get('price'.$i)*$session->get('quantity'.$i);?> kr</td>
                        </tr>
                        <?php
                            $total += ($session->get('price'.$i)*$session->get('quantity'.$i));
                            }
                        ?>
                            
                    </table>
                </td>
                </tr>
                <tr>
                <td style="text-align: right; color:#323232; font-size:12px; padding:0px; padding:2px 43px 50px 0; font-weight: bold;">At betale: <?php echo $total;?> kr</td>
                </tr>
             </table>
             <div id="prd-confirm-wrapper">
                  <a id="product-confirm" href="index.php?option=com_ecommerce&task=checkOut&comment=<?php echo JRequest::getVar('comment');?>">Confirm</a>
                  <div class="clear"></div>
            </div>
        </div>                 
    </div>			
</div>